﻿using System;

namespace Hrunga.PVCM.Framework
{

    /// <summary>
    /// The baseclass for all the presenters.
    /// </summary>
    /// <typeparam name="TView">The type of the view.</typeparam>
    public abstract class PresenterBase<TView> : IPresenter<TView>
        where TView : class, IView
    {

        public void Initialize(IView view)
        {
            this.View = view as TView;
            if (this.View != null)
            {
                this.View.ViewReady += (s, e) => StartPresenter();
            }
            else
            {
                throw new ArgumentException("Invalid view given.");
            }
        }

        protected abstract void StartPresenter();

        public TView View
        {
            private set;
            get;
        }
    }
}
